/**
 * @file childframe.h
 * @brief
 *
 * 
 *
 * @author 1823419256@qq.com
 * @version 1.0
 * @date 2011
*/

#ifndef MYBOOK_FRAME_CHILDFRAME_H_
#define MYBOOK_FRAME_CHILDFRAME_H_

typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0> CChildFrameTraits;

class CChildFrame : public CWindow
{
public:
	virtual void Accept(class CChildFrameInitVisitor* pVistor) = 0;
	virtual bool Equal(class CChildFrameTypeVisitor* pVistor) = 0;

	virtual void Show(bool bShow)
	{
		if (bShow)
		{
			CWindowRect rect(GetParent());
			SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_SHOWWINDOW);
		}
		else
		{
			ShowWindow(SW_HIDE);
		}
	}

	virtual void DataNotify()
	{

	}
};

class CChildFrameSimpleFactory
{
public:
	enum { CFT_HOME = 0, CFT_LIBRARY = 1, CFT_TOOLS = 2, CFT_HELP = 3 };

public:
	void GetCommandVec(std::vector<std::pair<int, CString>>& vecCmd);

public:
	CChildFrame* CreateFrame(int nIndex);
};

class CChildFrameInitVisitor
{
public:
	explicit CChildFrameInitVisitor(HWND hWnd)
		: m_hWnd(hWnd)
	{
	}

public:
	void FrameInitVisit(class CChildFrameHome* pChildFrame);
	void FrameInitVisit(class CChildFrameLibrary* pChildFrame);
	void FrameInitVisit(class CChildFrameTools* pChildFrame);
	void FrameInitVisit(class CChildFrameHelp* pChildFrame);
	void FrameInitVisit(class CChildFrameSnb* pChildFrame);

private:
	HWND m_hWnd;
};

class CChildFrameTypeVisitor
{
public:
	CChildFrameTypeVisitor(int nType)
		: m_nType(nType)
	{
	}

public:
	bool FrameTypeVisit(class CChildFrameHome* pChildFrame);
	bool FrameTypeVisit(class CChildFrameLibrary* pChildFrame);
	bool FrameTypeVisit(class CChildFrameTools* pChildFrame);
	bool FrameTypeVisit(class CChildFrameHelp* pChildFrame);
	bool FrameTypeVisit(class CChildFrameSnb* pChildFrame);

private:
	int	 m_nType;
};

#endif // MYBOOK_FRAME_CHILDFRAME_H_